package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.ArrangePeriod;
import com.dragon.repository.entity.ArrangePoints;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ArrangePeriodVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "时间设置主表id")
    private Integer id;

    @ApiModelProperty(value = "时段名称")
    private String PeriodName;

    @ApiModelProperty(value = "签到时间")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date inTime;

    @ApiModelProperty(value = "签退时间")
    @JsonFormat(pattern = "HH:mm:ss", timezone = "GMT+8")
    private Date outTime;

    @ApiModelProperty(value = "签到是否需要打卡0是1否")
    private Integer inClock;

    @ApiModelProperty(value = "签退是否需要打卡0是1否")
    private Integer outClock;

    @ApiModelProperty(value = "签到打卡设置：1不允许考勤点外打卡	2允许考勤点外打卡，记录为考勤点异常	3允许考勤点外打卡，记录为正常出勤")
    private Integer inClockSetting;

    @ApiModelProperty(value = "签退打卡设置：1不允许考勤点外打卡	2允许考勤点外打卡，记录为考勤点异常	3允许考勤点外打卡，记录为正常出勤")
    private Integer outClockSetting;

    @ApiModelProperty(value = "主配置id")
    private Integer arrangeId;

    @ApiModelProperty(value = "考勤点ids")
    private String pointsId;

    @NotNull(groups = Update.class,message = "主键不能为空")
    public static ArrangePeriod convert(ArrangePeriodVO vo) {
        ArrangePeriod entity = new ArrangePeriod();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<ArrangePeriod> convertList(List<ArrangePeriodVO> list) {
        List<ArrangePeriod> resultList = new ArrayList<>();
        for (ArrangePeriodVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
